#pragma once

#include "ast.h"
#include "parser.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/IRBuilder.h"

class CodeGen : public Visitor
{
public:
    CodeGen(std::shared_ptr<Program> program)
    {
        module = std::make_shared<llvm::Module> ("expr", context);
        VisitProgram(program.get());
    }

public:
    llvm::Value *VisitProgram(Program *p) override;
    llvm::Value *VisitBinaryExpr(BinaryExpr *binaryExpr) override;
    llvm::Value *VisitFactorExpr(FactorExpr *factorExpr) override;
private:
    llvm::LLVMContext context;
    llvm::IRBuilder<> irBuilder{context};
    std::shared_ptr<llvm::Module> module;
};